home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / tttsrc51.zip / MENUTTT5.PAS < prev    next >
Pascal/Delphi Source File  |  1993-01-04  |  25KB  |  638 lines

  1. {--------------------------------------------------------------------------}
  2. {                         TechnoJock's Turbo Toolkit                       }
  3. {                                                                          }
  4. {                              Version   5.10                              }
  5. {                                                                          }
  6. {                                                                          }
  7. {               Copyright 1986-1993 TechnoJock Software, Inc.              }
  8. {                           All Rights Reserved                            }
  9. {                          Restricted by License                           }
  10. {--------------------------------------------------------------------------}
  11.  
  12.                      {--------------------------------}
  13.                      {       Unit:  MenuTTT5          }
  14.                      {--------------------------------}
  15.  
  16.  
  17. {History:     2/13/89          Mod 5.00a changed Y2 calculation in proc
  18.                                Determine_Y_Dimensions
  19.                         5.01a  Removed refrences to VER50 and added DEBUG
  20.                                compiler directive 
  21.              01/04/93   5.10   DPMI compatible version
  22. }
  23.  
  24. {$S-,R-,V-}
  25. {$IFNDEF DEBUG}
  26. {$D-}
  27. {$ENDIF}
  28.  
  29. Unit MenuTTT5;
  30.  
  31. INTERFACE
  32.  
  33. Uses CRT, FastTTT5, DOS, WinTTT5, KeyTTT5, StrnTTT5;
  34.  
  35. const
  36.    Max_Choices = 30;
  37.    MenuStrLength = 40;     {make longer if necessary}
  38. type
  39. {$IFNDEF VER40}
  40.    Menu_Hook = Procedure(var Ch:char; Choice:integer; var Ecode:integer);
  41. {$ENDIF}
  42.    Menu_record = record
  43.                   Heading1     : string[MenuStrLength];   { '' for no heading}
  44.                   Heading2     : string[MenuStrLength];
  45.                   Topic        : array[1..Max_Choices] of string[MenuStrLength];
  46.                   TotalPicks   : integer;
  47.                   PicksPerLine : byte;
  48.                   AddPrefix    : byte;                    {0 no, 1 No.'s, 2 Lets}
  49.                   TopLeftXY    : array[1..2] of byte;     {X,Y}
  50.                   Boxtype      : byte;                    {0,1,2,3, >3}
  51.                   Colors       : array[1..5] of byte;     {HF,HB,LF,LB,Box}
  52.                   Margins      : byte;
  53.                   AllowEsc     : boolean;                 {true if Esc will exit}
  54.                   {$IFNDEF VER40}
  55.                   Hook         : Menu_hook;
  56.                   {$ENDIF}
  57.                 end;
  58. {$IFDEF VER40}
  59. Var
  60.   M_UserHook : Pointer;
  61. {$ENDIF}
  62. Procedure No_Hook(var Ch:char; Choice:integer; var Ecode : integer);
  63. Procedure Menu_Set(var M : Menu_record);
  64. Procedure DisplayMenu(MenuDef: Menu_record;
  65.                       Window:Boolean;
  66.                       var Choice,Errorcode : integer);
  67.  
  68. IMPLEMENTATION
  69.  
  70. {$IFDEF VER40}
  71.    Procedure Call_Hook(var Ch:char; Choice:integer; var Ecode:integer);
  72.           Inline($FF/$1E/M_UserHook);
  73. {$ENDIF}
  74.  
  75. {$F+}
  76.  Procedure No_Hook(var Ch:char; Choice:integer; var Ecode : integer);
  77.  {}
  78.  begin
  79.  end; {of proc No_Hook}
  80. {$F-}
  81.  
  82.  Procedure Menu_Set(var M : Menu_record);
  83.  {}
  84.  begin
  85.      with M do
  86.      begin
  87.          Heading1     := '';
  88.          Heading2     := '';
  89.          Topic[1]     := '';
  90.          TotalPicks   := 0;
  91.          PicksPerLine := 1;
  92.          AddPrefix    := 1;
  93.          TopLeftXY[1] := 0;
  94.          TopLeftXY[2] := 0;
  95.          Boxtype      := 5;
  96.          If ColorScreen then
  97.          begin
  98.              Colors[1]    := white;
  99.              Colors[2]    := red;
  100.              Colors[3]    := lightgray;
  101.              Colors[4]    := blue;;
  102.              Colors[5]    := lightred;
  103.          end
  104.          else
  105.          begin
  106.              Colors[1]    := white;
  107.              Colors[2]    := black;
  108.              Colors[3]    := lightgray;
  109.              Colors[4]    := black;
  110.              Colors[5]    := white;
  111.          end;
  112.          Margins      := 5;
  113.          AllowEsc     := true;
  114.          {$IFNDEF VER40}
  115.                  Hook         := NO_Hook;
  116.          {$ELSE}
  117.                  M_UserHook := Nil;
  118.          {$ENDIF}
  119.      end;
  120.  end; {of proc Menu_Set}
  121.  
  122.  Procedure MenuError(Code:byte);    {fatal error -- msg and halt}
  123.  var Message:string;
  124.  begin
  125.      {Clrscr;}
  126.      Case Code of
  127.      1 : Message := 'Fatal Error 1: Too Many Picks to display. Change PicksPerLine';
  128.      else Message := 'Aborting';
  129.      end; {case}
  130.      WriteAT(1,12,black,lightgray,Message);
  131.      Repeat Until keypressed;
  132.      Halt;
  133.  end;    {proc MenuError}
  134.  
  135. Procedure DisplayMenu(MenuDef: Menu_record;
  136.                       Window:Boolean;
  137.                       var Choice,Errorcode : integer);
  138. Const
  139. Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  140. Numbers  = '123456789';
  141. var
  142. I,J,X2,Y2,heading_Lines : integer;
  143. TextWidth : byte;
  144.  
  145.  
  146.     Function Int_to_Str(Number:Integer):string;
  147.     var Temp : string;
  148.     begin
  149.        Str(Number,temp);
  150.        Int_to_Str := temp;
  151.     end;
  152.  
  153.     Function  Str_to_Int(Str:string):integer;
  154.     var temp,code : integer;
  155.     begin
  156.         If length(Str) = 0 then
  157.            Str_to_Int := 0
  158.         else
  159.         begin
  160.             val(Str,temp,code);
  161.             if code = 0 then
  162.                Str_to_Int := temp
  163.             else
  164.                Str_to_Int := 0;
  165.         end;
  166.     end;
  167.  
  168.    Procedure GetDimensions;
  169.    var Fullwidth,MaxWidth: integer;
  170.  
  171.      Procedure Validate_Prefix;                          { 0   no prefix  }
  172.      begin                                               { 1   numbers prefix}
  173.          with MenuDef do                                 { 2   letters prefix}
  174.          begin                                           { 3   function key prefix}
  175.              If PicksPerLine < 1 then PicksPerLine := 1; { 4   capital letter selection}
  176.              If (TotalPicks = 10) and (AddPrefix = 1) then
  177.                 AddPrefix := 3;
  178.              If (TotalPicks > 10) and (AddPrefix in [1,3]) then
  179.                 AddPrefix := 2;
  180.              If (Addprefix > 4) or (TotalPicks > 26) or (Addprefix < 0) then
  181.                 Addprefix := 0;
  182.              end; {do}
  183.      end; {Validate_Prefix}
  184.  
  185.    Procedure Add_Prefix;
  186.    var I : integer;
  187.    begin
  188.        With MenuDef do
  189.        begin
  190.            Case AddPrefix of
  191.            1 : for I := 1 to TotalPicks do
  192.                    Topic[I] := int_to_str(I) + ' ' + Topic[I];
  193.            2 : for I := 1 to TotalPicks do
  194.                    Topic[I] := Copy(Alphabet,I,1) + ' ' + Topic[I];
  195.            3 : If TotalPicks < 10 then
  196.                   for I := 1 to TotalPicks do
  197.                       Topic[I] := 'F'+Int_to_Str(I) + ' ' + Topic[I]
  198.                else
  199.                begin                           {add extra space for F10 }
  200.                    for I := 1 to 9 do
  201.                        Topic[I] := 'F'+Int_to_Str(I) + '  ' + Topic[I];
  202.                    Topic[10] := 'F10 '+ Topic[10];
  203.                end;
  204.            end; {case}
  205.        end;  {do}
  206.    end;  {proc Add_Prefix}
  207.  
  208.      Procedure Find_Longest_Topic;
  209.      var
  210.        I,J: integer;
  211.      begin
  212.          with MenuDef do
  213.          begin
  214.              Textwidth := 0;
  215.              For I := 1 to TotalPicks do
  216.                  If length(Topic[I]) > TextWidth then
  217.                     Textwidth := length(Topic[I]);         {find the longest text}
  218.          end;  {with}
  219.      end;   {Proc Find_Widest_Line}
  220.  
  221.    Procedure Adjust_Text_Width(Len:integer);
  222.    var I,J : integer;
  223.    begin
  224.        With MenuDef do
  225.        begin
  226.            For I := 1 to TotalPicks do
  227.                If length(Topic[I]) > Len then         {reduce it}
  228.                   Delete(Topic[I],succ(Len),length(Topic[I]) - Len)
  229.                else                                  {expand it}
  230.                   For J := length(Topic[I]) + 1 to Textwidth do
  231.                       Topic[I] :=  Topic[I] + ' ';
  232.        end; {do}
  233.    end;
  234.  
  235.    Procedure Determine_MaxWidth;
  236.    {findout the max internal menu space - MaxWidth}
  237.    begin
  238.        with MenuDef do
  239.        begin
  240.            If margins < 0 then Margins := 0;
  241.            If not (BoxType in [0..9]) then
  242.               BoxType := 0;
  243.            MaxWidth := 80 - 2*Margins - 1; {-1 for arrow symbol to left of pick}
  244.            Case BoxType of
  245.            1..4 : MaxWidth := MaxWidth - 2;     {box sides}
  246.            5    : MaxWidth := pred(MaxWidth);    {box shadow}
  247.            6..9 : MaxWidth := MaxWidth - 3;     {box sides and shadow}
  248.            end;
  249.        end; {with}
  250.    end;
  251.  
  252.    Procedure Validate_PicksPerLine;
  253.    begin
  254.        With MenuDef do
  255.        begin
  256.            If succ(TextWidth)*PicksPerLine <= MaxWidth then
  257.               exit;  {no adjustment necessary, everything fits}
  258.            If (TextWidth-2)*PicksPerLine <= Maxwidth  then
  259.                TextWidth := pred(MaxWidth div PicksperLine)
  260.            else
  261.            begin
  262.                While succ(TextWidth)*PicksPerLine > MaxWidth do
  263.                      PicksPerLine := pred(PicksPerLine);
  264.                If PicksPerLine = 0 then
  265.                begin
  266.                    TextWidth := pred(MaxWidth);
  267.                    PicksPerLine := 1;
  268.                end;
  269.            end;
  270.        end; {with}
  271.    end;  {Proc Validate_PicksPerLine}
  272.  
  273.    Procedure Determine_X_Dimensions;
  274.    {Checks to see if the menu will fit, if it won't it changes something!}
  275.    begin
  276.        With MenuDef do
  277.        begin
  278.            Fullwidth := succ(Textwidth)*PicksPerLine + 2*Margins;
  279.            Case BoxType of
  280.            1..4 : FullWidth := FullWidth + 2;     {box sides}
  281.            5    : FullWidth := succ(FullWidth);   {box shadow}
  282.            6..9 : FullWidth := FullWidth + 3;     {box sides and shadow}
  283.            end; {Case}
  284.            If TopleftXY[1] < 1 then
  285.               TopleftXY[1] := (80 - Fullwidth)  div 2;
  286.            If TopLeftXY[1] + Fullwidth < 80 then
  287.               X2 := TopleftXY[1] + Fullwidth
  288.            else
  289.            begin
  290.                X2 := 80;
  291.                TopLeftXY[1] := 80 - Fullwidth + 1;
  292.            end;
  293.        end; {with}
  294.    end; {Proc Determine_X_Dimensions}
  295.  
  296.    Procedure Determine_Y_Dimensions;
  297.    var
  298.       BoxLines,
  299.       TopicLines,
  300.       FullDepth  : integer;
  301.    begin
  302.        With MenuDef do
  303.        begin
  304.            TopicLines := TotalPicks div PicksPerLine;  {no of full rows of picks}
  305.            If TotalPicks mod PicksPerLine > 0 then     {+1 if partial row of picks}
  306.               TopicLines := succ(TopicLines);
  307.            Case BoxType of
  308.            0    : Boxlines := 0;
  309.            1..5 : BoxLines :=  2;     {box sides}
  310.            6..9: BoxLines :=  3;     {box sides and shadow}
  311.            end;
  312.            Heading_Lines := 0;
  313.            If length(Heading1) > 0 then
  314.               Heading_Lines := succ(Heading_Lines);
  315.            If length(Heading2) > 0 then
  316.               Heading_Lines := succ(Heading_Lines);
  317.            If Heading_Lines > 0 then                   {add a line for a gap}
  318.               Heading_Lines := succ(Heading_Lines);    {gap above topics}
  319.            If BoxType = 5 then
  320.               Heading_Lines := succ(Heading_Lines);
  321.            Fulldepth := BoxLines+TopicLines+Heading_Lines;
  322.            If Heading_Lines > 0 then
  323.              Fulldepth := succ(Fulldepth);  {+1 gap below topics if headings}
  324.            If FullDepth > DisplayLines then   {if it doesn't fit, drop off topics}
  325.            begin
  326.                If Heading_Lines > 0 then
  327.                   TotalPicks :=  (DisplayLines - BoxLines -Heading_Lines-1)*PicksPerLine
  328.                else
  329.                   TotalPicks :=  (DisplayLines - BoxLines - Heading_Lines)*PicksPerLine;
  330.                FullDepth := 25;
  331.            end;
  332.            If TopLeftXY[2] <= 0 then
  333.               TopLeftXY[2] := (DisplayLines - Fulldepth) div 2 +1;
  334.            If TopLeftXY[2] + Fulldepth - 1 <= DisplayLines then
  335.            begin
  336.                If BoxType > 4 then   {shadow}
  337.                   Y2 := TopleftXY[2] + (Fulldepth) - 2     {Mod 5.00a}
  338.                else
  339.                   Y2 := TopleftXY[2] + pred(Fulldepth);    {Mod 5.00a}
  340.            end
  341.            else
  342.            begin
  343.                If BoxType > 4 then   {shadow}
  344.                   Y2 := pred(DisplayLines)
  345.                else
  346.                   Y2 := DisplayLines;
  347.                TopLeftXY[2] := DisplayLines - Fulldepth {+ 1};   {WZ}
  348.            end;
  349.    end;   {do}
  350.    end; {Proc Determine_Y_Dimensions}
  351.  
  352.    begin                              {Get_Dimensions}
  353.        Validate_Prefix;
  354.        Add_Prefix;
  355.        Find_Longest_Topic;
  356.        Determine_MaxWidth;
  357.        Validate_PicksPerLine;
  358.        Adjust_Text_Width(TextWidth);
  359.        Determine_X_Dimensions;
  360.        Determine_Y_Dimensions;
  361.    end;   {proc GetDimensions}
  362.  
  363.    Procedure Write_Text(Item:integer;Highlight:boolean);
  364.    Var X,Y,A:integer;
  365.    begin
  366.        With MenuDEf do
  367.        begin
  368.            A := Item mod PicksPerLine;
  369.            Y := Item div PicksPerLine +TopleftXY[2] + ord(A <> 0);
  370.            Y := Y + Heading_lines - ord(Boxtype = 0);
  371.            If A = 0 then A := PicksPerLine;      {A is now the no of picks from left}
  372.            X := (A - 1)*(TextWidth + 1)+Margins+
  373.                 TopleftXY[1]+1 + ord(BoxType > 0);          {title width + 1 for a space}
  374.            If Highlight then
  375.            begin
  376.                WriteAt(X,Y,colors[1],colors[2],Topic[item]);
  377.                WriteAT(pred(X),Y,colors[5],colors[2],chr(16));  {write arrow head}
  378.            end
  379.            else
  380.            begin
  381.                WriteAT(X,Y,colors[3],colors[4],Topic[item]);
  382.                WriteAT(pred(X),Y,colors[3],colors[4],' ');       {remove arrow head}
  383.                If AddPrefix = 4 then                             {highlight the capital letter}
  384.                   WriteAT(Pred(X)+First_Capital_Pos(Topic[Item]),Y,
  385.                           colors[1],colors[4],
  386.                           First_Capital(Topic[Item]));
  387.            end;
  388.        end;  {do}
  389.    end;  {Proc Write_Text}
  390.  
  391.    Procedure CreateMenu;
  392.    var I : integer;
  393.    begin
  394.    with MenuDef do
  395.    begin
  396.     If Window then
  397.            MkWin(TopleftXY[1],TopLeftXY[2],X2,Y2,colors[3],colors[4],boxtype)
  398.     else
  399.     begin
  400.         ClearText(TopleftXY[1],TopLeftXY[2],X2,Y2,colors[3],colors[4]);
  401.         If (BoxType in [5..9]) and (TopleftXY[1] > 1) then      {draw a shadow}
  402.         begin
  403.             For I := TopleftXY[2]+1 to Y2+1 do
  404.                 WriteAt(pred(TopLeftXY[1]),I,colors[3],black,' ');
  405.             WriteAt(TopLeftXY[1],succ(Y2),colors[3],black,
  406.                 replicate(X2-succ(TopLeftXY[1]),' '));
  407.         end;
  408.     end;
  409.     Case Boxtype of
  410.     1..4: Box(TopLeftXY[1],TopLeftXY[2],X2,Y2,colors[5],colors[4],Boxtype);
  411.     5   : begin
  412.               WriteAT(TopleftXY[1],TopleftXY[2],colors[5],colors[4],
  413.                       replicate(succ(X2 - TopleftXY[1]),chr(223)));
  414.               WriteAT(TopleftXY[1],TopleftXY[2]+Heading_Lines-1,colors[5],colors[4],
  415.                       replicate(succ(X2 - TopleftXY[1]),chr(196)));
  416.           end;
  417.     6..9:Box(TopLeftXY[1],TopLeftXY[2],X2,Y2,colors[5],colors[4],Boxtype-5);
  418.     end; {case}
  419.  
  420.     If length(Heading1) > 0 then
  421.        WriteBetween(TopleftXY[1],X2,
  422.                     TopLeftXY[2]+ord(BoxType > 0),
  423.                     colors[1],colors[4],Heading1);
  424.     If length(Heading2) > 0 then
  425.        WriteBetween(TopleftXY[1],X2,
  426.                     TopLeftXY[2]+ord(BoxType > 0)+ord(Heading_Lines <> 2),
  427.                     colors[1],colors[4],Heading2);
  428.     For I := 1 to TotalPicks do
  429.         Write_Text(I,false);
  430.     Write_Text(Choice,True);       {Highlight Default}
  431.    end; {do}
  432.    end; {Proc CreateMenu}
  433.  
  434.    Procedure Process_Keystrokes;
  435.    var
  436.      Found,
  437.      Selected: Boolean;
  438.      ChT,
  439.      CHpk:char;
  440.      Oldchoice:integer;
  441.      I,
  442.      Ecode:integer;
  443.      ScanTop,ScanBot,Cx,Cy : byte;
  444.    begin
  445.        Selected := false;
  446.        Found := false;
  447.        FindCursor(Cx,Cy,ScanTop,ScanBot);
  448.        OffCursor;
  449.        With MenuDef do
  450.        begin
  451.        Repeat
  452.              Chpk := GetKey;
  453. {$IFNDEF VER40}
  454.              MenuDef.Hook(Chpk,Choice,Ecode);   {call the user hook}
  455. {$ELSE}
  456.              If M_UserHook <> Nil then
  457.                 Call_Hook(Chpk,Choice,Ecode);
  458. {$ENDIF}
  459.              Case upcase(CHpk) of
  460.              #208 : begin       {Cursor Down}
  461.                         Write_text(Choice,false);
  462.                         Choice := Choice + PicksPerLine;
  463.                         If Choice > TotalPicks then
  464.                            Choice := (Choice mod PicksPerLine) + 1;
  465.                         Write_Text(Choice,true);
  466.                     end;
  467.              #129 : If Choice + PicksPerLine  <= TotalPicks then  {Mouse Down}
  468.                     begin
  469.                         Write_text(Choice,false);
  470.                         Choice := Choice + PicksPerLine;
  471.                         Write_Text(Choice,true);
  472.                     end;
  473.              #200 : begin       {cursor up}
  474.                         Write_Text(Choice,false);
  475.                         Choice := Choice - PicksPerLine;
  476.                         If Choice < 1 then
  477.                         begin
  478.                            Choice := Choice + PicksPerline;
  479.                            Choice :=
  480.                              ((TotalPicks div PicksPerLine)*PicksPerLine)
  481.                              - PicksPerLine + 1 + Choice - 2;
  482.                            If Choice + PicksPerLine <= TotalPicks then
  483.                               Choice := Choice + PicksPerLine;   {phew!}
  484.                         end;
  485.                         Write_Text(Choice,true);
  486.                     end;
  487.              #128 : If Choice - PicksPerLine > 0 then   {Mouse up}
  488.                     begin
  489.                         Write_Text(Choice,false);
  490.                         Choice := Choice - PicksPerLine;
  491.                         Write_Text(Choice,true);
  492.                     end;
  493.              #203 : begin       {cursor left}
  494.                         Write_Text(Choice,False);
  495.                         Choice := pred(choice);
  496.                         If choice = 0 then Choice := TotalPicks;
  497.                         Write_Text(Choice,true);
  498.                     end;
  499.              #130 : If (pred(Choice) > 0)  {mouse left}
  500.                     and ( Choice mod PicksPerLine <> 1) then
  501.                     begin
  502.                         Write_Text(Choice,False);
  503.                         Choice := pred(choice);
  504.                         Write_Text(Choice,true);
  505.                     end;
  506.              ' ',
  507.              #205 : begin        {cursor right}
  508.                         Write_Text(Choice,false);
  509.                         Choice := succ(Choice);
  510.                         If choice > TotalPicks then Choice := 1;
  511.                         Write_Text(Choice,true);
  512.                     end;
  513.              #131 : If (succ(Choice) <= TotalPicks) {Mouse right}
  514.                     and ( Choice mod PicksPerLine <> 0) then
  515.                     begin
  516.                         Write_Text(Choice,false);
  517.                         Choice := succ(Choice);
  518.                         Write_Text(Choice,true);
  519.                     end;
  520.              #199 : begin         {home key}
  521.                         Write_Text(Choice,false);
  522.                         Choice := 1;
  523.                         Write_Text(Choice,true);
  524.                     end;
  525.              #207 : begin         {end key}
  526.                         Write_Text(Choice,false);
  527.                         Choice := TotalPicks;
  528.                         Write_Text(Choice,true);
  529.                     end;
  530.              #133,                 {Mouse enter}
  531.              #13  : begin          {enter key}
  532.                         Selected := true;
  533.                         Errorcode := 0;
  534.                     end;
  535.              #0   : begin
  536.                         Selected := true;
  537.                         ErrorCode := Ecode;
  538.                     end;
  539.              #132,                    {Mouse Esc}
  540.              #27  : If AllowEsc then  {Esc}
  541.                     begin
  542.                         Selected := true;
  543.                         ErrorCode := 1;
  544.                     end
  545.                     else
  546.                     begin
  547.                         Write_Text(Choice,false);
  548.                         Choice := TotalPicks;
  549.                         Write_Text(Choice,true);
  550.                     end;
  551.              #187..#196 : If Addprefix = 3 then   {F1 to F10}
  552.                           begin
  553.                               Oldchoice := Choice;
  554.                               Case Upcase(Chpk) of
  555.                               #187 : If TotalPicks >= 1  then choice := 1 else choice := 0;
  556.                               #188 : If TotalPicks >= 2  then choice := 2 else choice := 0;
  557.                               #189 : If TotalPicks >= 3  then choice := 3 else choice := 0;
  558.                               #190 : If TotalPicks >= 4  then choice := 4 else choice := 0;
  559.                               #191 : If TotalPicks >= 5  then choice := 5 else choice := 0;
  560.                               #192 : If TotalPicks >= 6  then choice := 6 else choice := 0;
  561.                               #193 : If TotalPicks >= 7  then choice := 7 else choice := 0;
  562.                               #194 : If TotalPicks >= 8  then choice := 8 else choice := 0;
  563.                               #195 : If TotalPicks >= 9  then choice := 9 else choice := 0;
  564.                               #196 : If TotalPicks >= 10 then choice := 10 else choice := 0;
  565.                               end;  {case}
  566.                               If Choice = 0 then
  567.                                  Choice := Oldchoice
  568.                               else
  569.                               begin
  570.                                   Write_Text(Oldchoice,false);
  571.                                   Write_Text(Choice,true);
  572.                                   Selected := true;
  573.                                   Errorcode := 0;
  574.                               end;
  575.                           end;
  576.              '0'..'9': If (AddPrefix in [1,3]) then   {Number or Function Prefix} {4.02}
  577.                        begin
  578.                            If (Str_to_int(CHpk) in [1..TotalPicks]) then
  579.                            begin
  580.                                Write_Text(Choice,false);
  581.                                Choice := Str_to_Int(CHpk);
  582.                                Write_Text(Choice,true);
  583.                                Selected := true;
  584.                                ErrorCode := 0;
  585.                            end;
  586.                        end;
  587.              'A'..'Z': If AddPrefix = 2 then
  588.                        begin
  589.                           If (pos(upcase(CHpk),Alphabet) in [1..TotalPicks]) then
  590.                           begin
  591.                               Write_Text(Choice,false);
  592.                               Choice := pos(upcase(CHpk),Alphabet);
  593.                               Write_Text(Choice,true);
  594.                               Selected := true;
  595.                               Errorcode := 0;
  596.                           end;
  597.                        end
  598.                        else
  599.                        begin
  600.                            If AddPrefix = 4 then
  601.                            begin
  602.                                Found := false;
  603.                                I := Choice;
  604.                                Repeat
  605.                                     If First_Capital(Topic[I]) = upcase(ChPk) then
  606.                                     begin
  607.                                         Found := true;
  608.                                         Write_Text(Choice,false);
  609.                                         Choice := I;
  610.                                         Write_Text(Choice,true);
  611.                                         Selected := true;
  612.                                         Errorcode := 0;
  613.                                     end
  614.                                     else
  615.                                         If I = TotalPicks then
  616.                                            I := 1
  617.                                         else
  618.                                            Inc(I);
  619.                                Until Found or (I = Choice);
  620.                            end;
  621.                         end;
  622.                     end;
  623.        Until Selected;
  624.        SizeCursor(ScanTop,ScanBot);
  625.        end; {do}
  626.   end; {proc Process_keystrokes}
  627.  
  628. begin
  629.    GetDimensions;
  630.    CreateMenu;
  631.    Horiz_Sensitivity := 2;  {two cursors left/right before mouse returns a keypress}
  632.    Process_Keystrokes;
  633.    If Window then RmWin;
  634. end;        {Main Procedure DisplayMenu}
  635.  
  636. begin
  637. end.
  638.